﻿#region License
/* Copyright (C) 2009 Tim Coulter
 * 
 * This file is part of ExtremeML.
 * 
 * ExtremeML is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation either version
 * 2 of the License, or (at your option) any later version.
 * 
 * ExtremeML is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
 * the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
*/
#endregion

using System;

namespace ExtremeML.Builder
{
	/// <summary>
	/// Maps a wrapper property to its corresponding property on the wrapped instance.
	/// </summary>
	public class WrapperPropertyMapping
	{
		/// <summary>
		/// Gets or sets the <see cref="PropertyCategory"/> of the property served by this mapping.
		/// </summary>
		public PropertyCategory Category { get; set; }

		/// <summary>
		/// Gets or sets the type name of the wrapper property served by this mapping.
		/// </summary>
		public string TypeName { get; set; }

		/// <summary>
		/// Gets or sets the name of the wrapper property served by this mapping
		/// </summary>
		public string PropertyName { get; set; }

		/// <summary>
		/// Gets the name of the wrapper property backing field served by this mapping
		/// </summary>
		public string BackingFieldName
		{
			get { return "_" + PropertyName.Substring(0, 1).ToLower() + PropertyName.Substring(1); }
		}

		/// <summary>
		/// Gets or sets the name of the mapped property on the wrapped instance.
		/// </summary>
		public string MappedProperty { get; set; }

		/// <summary>
		/// Gets or set the <see cref="Type"/> of the mapped property on the wrapped instance.
		/// </summary>
		public Type MappedType { get; set; }

		/// <summary>
		/// Gets or sets the expression used to load the wrapper property value from the wrapped instance.
		/// </summary>
		public string LoadExpression { get; set; }

		/// <summary>
		/// Gets or sets the expression used to save the wrapper property value to the wrapped instance.
		/// </summary>
		public string SaveExpression { get; set; }

		/// <summary>
		/// Gets or sets whether this property has a public get accessor.
		/// </summary>
		public bool CanGet { get; set; }

		/// <summary>
		/// Gets or sets whether this property has a public set accessor.
		/// </summary>
		public bool CanSet { get; set; }
	}
}
